<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>子集问题 - 回溯算法详解</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
        }
        .serif-font {
            font-family: 'Noto Serif SC', serif;
        }
        .gradient-text {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        .hero-pattern {
            background-color: #f8fafc;
            background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%239C92AC' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
        }
        .code-block {
            background: linear-gradient(135deg, #1e1e2e 0%, #2d2d44 100%);
            border-radius: 12px;
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .hover-scale {
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }
        .hover-scale:hover {
            transform: translateY(-4px);
            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
        }
        .drop-cap::first-letter {
            float: left;
            font-size: 4rem;
            line-height: 3rem;
            padding-right: 0.5rem;
            margin-top: 0.5rem;
            font-weight: 700;
            color: #667eea;
        }
        pre {
            margin: 0;
            padding: 0;
        }
        code {
            font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
        }
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-pattern relative overflow-hidden">
        <div class="container mx-auto px-6 py-20">
            <div class="max-w-4xl mx-auto text-center">
                <div class="mb-6">
                    <span class="inline-flex items-center px-4 py-2 rounded-full text-sm font-medium bg-purple-100 text-purple-800">
                        <i class="fas fa-code mr-2"></i>
                        算法精讲
                    </span>
                </div>
                <h1 class="text-5xl md:text-6xl font-bold mb-6 serif-font">
                    <span class="gradient-text">子集问题</span>
                </h1>
                <p class="text-xl text-gray-600 leading-relaxed">
                    探索回溯算法的优雅之美，掌握生成所有可能子集的核心技巧
                </p>
            </div>
        </div>
        <div class="absolute bottom-0 left-0 right-0 h-20 bg-gradient-to-t from-gray-50 to-transparent"></div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto px-6 py-16 max-w-6xl">
        <!-- Problem Description -->
        <section class="mb-16">
            <div class="bg-white rounded-2xl shadow-xl p-8 hover-scale">
                <div class="flex items-center mb-6">
                    <div class="w-12 h-12 bg-gradient-to-br from-purple-500 to-pink-500 rounded-lg flex items-center justify-center text-white mr-4">
                        <i class="fas fa-tasks text-xl"></i>
                    </div>
                    <h2 class="text-3xl font-bold">题目描述</h2>
                </div>
                <p class="text-lg text-gray-700 leading-relaxed drop-cap">
                    给定一个不含重复元素的整数数组 nums，返回该数组所有可能的子集（幂集）。解集不能包含重复的子集。这是一道经典的回溯算法题目，通过递归的方式探索所有可能的组合，展现了算法设计的精妙之处。
                </p>
            </div>
        </section>

        <!-- Core Concepts -->
        <section class="mb-16 grid md:grid-cols-2 gap-8">
            <div class="bg-white rounded-2xl shadow-xl p-8 hover-scale">
                <div class="flex items-center mb-6">
                    <div class="w-10 h-10 bg-gradient-to-br from-blue-500 to-cyan-500 rounded-lg flex items-center justify-center text-white mr-3">
                        <i class="fas fa-brain"></i>
                    </div>
                    <h3 class="text-2xl font-bold">核心考点</h3>
                </div>
                <div class="space-y-4">
                    <div class="flex items-start">
                        <i class="fas fa-check-circle text-green-500 mt-1 mr-3"></i>
                        <div>
                            <h4 class="font-semibold text-lg mb-1">回溯算法</h4>
                            <p class="text-gray-600">通过系统地搜索所有可能的候选解来找出所有解的算法</p>
                        </div>
                    </div>
                    <div class="flex items-start">
                        <i class="fas fa-check-circle text-green-500 mt-1 mr-3"></i>
                        <div>
                            <h4 class="font-semibold text-lg mb-1">递归思维</h4>
                            <p class="text-gray-600">将复杂问题分解为相似的子问题，逐步求解</p>
                        </div>
                    </div>
                </div>
            </div>

            <div class="bg-white rounded-2xl shadow-xl p-8 hover-scale">
                <div class="flex items-center mb-6">
                    <div class="w-10 h-10 bg-gradient-to-br from-orange-500 to-red-500 rounded-lg flex items-center justify-center text-white mr-3">
                        <i class="fas fa-clock"></i>
                    </div>
                    <h3 class="text-2xl font-bold">复杂度分析</h3>
                </div>
                <div class="space-y-4">
                    <div class="bg-gray-50 rounded-lg p-4">
                        <h4 class="font-semibold text-lg mb-2 flex items-center">
                            <i class="fas fa-hourglass-half text-purple-500 mr-2"></i>
                            时间复杂度
                        </h4>
                        <p class="text-2xl font-mono font-bold text-purple-600">O(2^n)</p>
                        <p class="text-sm text-gray-600 mt-1">每个元素都有选择和不选择两种状态</p>
                    </div>
                    <div class="bg-gray-50 rounded-lg p-4">
                        <h4 class="font-semibold text-lg mb-2 flex items-center">
                            <i class="fas fa-memory text-blue-500 mr-2"></i>
                            空间复杂度
                        </h4>
                        <p class="text-2xl font-mono font-bold text-blue-600">O(n)</p>
                        <p class="text-sm text-gray-600 mt-1">递归调用栈的深度</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Solution Approach -->
        <section class="mb-16">
            <div class="bg-gradient-to-r from-purple-50 to-pink-50 rounded-2xl p-8">
                <div class="flex items-center mb-6">
                    <div class="w-12 h-12 bg-white rounded-lg shadow-lg flex items-center justify-center mr-4">
                        <i class="fas fa-lightbulb text-yellow-500 text-xl"></i>
                    </div>
                    <h2 class="text-3xl font-bold">解题思路</h2>
                </div>
                <div class="grid md:grid-cols-3 gap-6">
                    <div class="bg-white rounded-xl p-6 shadow-md hover-scale">
                        <div class="text-4xl font-bold text-purple-500 mb-3">01</div>
                        <h4 class="font-semibold text-lg mb-2">初始化结果集</h4>
                        <p class="text-gray-600">创建空列表存储所有子集，准备递归遍历</p>
                    </div>
                    <div class="bg-white rounded-xl p-6 shadow-md hover-scale">
                        <div class="text-4xl font-bold text-pink-500 mb-3">02</div>
                        <h4 class="font-semibold text-lg mb-2">递归选择元素</h4>
                        <p class="text-gray-600">对每个元素决定是否加入当前子集</p>
                    </div>
                    <div class="bg-white rounded-xl p-6 shadow-md hover-scale">
                        <div class="text-4xl font-bold text-indigo-500 mb-3">03</div>
                        <h4 class="font-semibold text-lg mb-2">回溯恢复状态</h4>
                        <p class="text-gray-600">撤销选择，继续探索其他可能性</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Visualization -->
        <section class="mb-16">
            <div class="bg-white rounded-2xl shadow-xl p-8">
                <div class="flex items-center mb-6">
                    <div class="w-12 h-12 bg-gradient-to-br from-green-500 to-teal-500 rounded-lg flex items-center justify-center text-white mr-4">
                        <i class="fas fa-project-diagram text-xl"></i>
                    </div>
                    <h2 class="text-3xl font-bold">算法可视化</h2>
                </div>
                <div class="mermaid">
                    graph TD
                        A["[]"] --> B["[]"]
                        A --> C["[1]"]
                        B --> D["[]"]
                        B --> E["[2]"]
                        C --> F["[1]"]
                        C --> G["[1,2]"]
                        D --> H["[]"]
                        D --> I["[3]"]
                        E --> J["[2]"]
                        E --> K["[2,3]"]
                        F --> L["[1]"]
                        F --> M["[1,3]"]
                        G --> N["[1,2]"]
                        G --> O["[1,2,3]"]
                        
                        style A fill:#f9f,stroke:#333,stroke-width:4px
                        style H fill:#9f9,stroke:#333,stroke-width:2px
                        style I fill:#9f9,stroke:#333,stroke-width:2px
                        style J fill:#9f9,stroke:#333,stroke-width:2px
                        style K fill:#9f9,stroke:#333,stroke-width:2px
                        style L fill:#9f9,stroke:#333,stroke-width:2px
                        style M fill:#9f9,stroke:#333,stroke-width:2px
                        style N fill:#9f9,stroke:#333,stroke-width:2px
                        style O fill:#9f9,stroke:#333,stroke-width:2px
                </div>
                <p class="text-center text-gray-600 mt-4">
                    <i class="fas fa-info-circle mr-2"></i>
                    回溯树展示了数组 [1, 2, 3] 生成所有子集的过程
                </p>
            </div>
        </section>

        <!-- Code Implementation -->
        <section class="mb-16">
            <div class="bg-white rounded-2xl shadow-xl overflow-hidden">
                <div class="bg-gradient-to-r from-purple-600 to-pink-600 p-6">
                    <div class="flex items-center">
                        <i class="fas fa-code text-white text-2xl mr-4"></i>
                        <h2 class="text-2xl font-bold text-white">示例代码</h2>
                    </div>
                </div>
                <div class="code-block p-6">
                    <pre><code class="text-gray-300 text-sm leading-relaxed"><span class="text-purple-400">def</span> <span class="text-blue-300">subsets</span>(<span class="text-orange-300">nums</span>):
    <span class="text-gray-500"># 初始化结果列表</span>
    result = []
    